package com.zzj.controller;

import com.github.pagehelper.PageInfo;
import com.zzj.bean.AssembleBean;
import com.zzj.service.AssembleService;
import com.zzj.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api
//@CrossOrigin
@RequestMapping("assemble")
public class AssembleController {
    @Autowired
    private AssembleService assembleService;

    @GetMapping("findAll")
    public PageInfo<AssembleBean> findAll(
            @RequestParam(defaultValue = "1") int pageNum,
            @RequestParam(defaultValue = "5") int pageSize
    ){
        return assembleService.findAll(pageNum,pageSize);
    }

    @PostMapping("updateAssemble")
    @ApiOperation("提交出箱表")
    public Result updateAssemble(@RequestBody AssembleBean assembleBean){
        System.out.println("assembleBean = " + assembleBean);
        return assembleService.updateAssemble(assembleBean);
    }

    @GetMapping("findByState")
    public List<AssembleBean> findByState(){
        return assembleService.findByState("2");
    }
}
